package com.weiyuwqj.server.service.sys.impl;


import com.weiyuwqj.api.model.SysAppSettings;
import com.weiyuwqj.api.service.SysAppSettingsService;
import com.weiyuwqj.server.mapper.SysAppSettingsMapper;
import com.weiyuwqj.server.service.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.InvocationTargetException;

/**
 * Created by huzj on 2016/9/21.
 */
@Service("appSettingService")
public class SysAppSettingsServiceImpl extends BaseServiceImpl<SysAppSettings> implements SysAppSettingsService {
    @Autowired
    SysAppSettingsMapper appSettingsMapper;


    @Override
    public SysAppSettings getAppSettingsByUserId(Integer userId) {
        return appSettingsMapper.getAppSettingsByUserId(userId);
    }

    @Override
    public int updateSetting(SysAppSettings appSettings) {
        SysAppSettings oldSetting = appSettingsMapper.getAppSettingsByUserId(appSettings.getUserId());
        appSettings.setId(oldSetting.getId());
        return appSettingsMapper.updateByPrimaryKeySelective(appSettings);
    }
}
